package BanyuanClub.Study.Day0309.锁相关2;

public class GuanTou {
    public  int rou = 1;

    //同步锁方法
    public synchronized void eated(){
        if (rou > 0){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            rou -= 1;
            System.out.println(Thread.currentThread() + "吃了块肉");
        }
        System.out.println("还剩" + this.rou + "块肉");
    }
}
